﻿using System;
using Kooboo.CMS.Content.Models;
using TestKooboo.Models;
using KB;
using KB.Subscribers;
using Kooboo.CMS.Content.Caching;
using Kooboo.CMS.Content.Persistence.Caching;
namespace TestKooboo.Subscribers
{
    public class ArticleSubscriber : Subscriber
    {
        public override void PreAdd(TextContent content)
        {
            content[Article.KEY.Title] += " From subcriber ";

            if (CacheUtility.Get("Hello") == null)
            {
                var s = "Test Cache";
                CacheUtility.Add("Hello", s);
            }
            content[Article.KEY.Title] += (string)CacheUtility.Get("Hello");
        }

        //public override void PreDelete(TextContent content)
        //{
        //    var article = content.MapTo<Article>();
        //    switch(article.FolderName)
        //    {
        //        case "AnotherFolderWithTheSameShema":
        //            break;
        //        default:
        //            article.Title = article.UUID + " Deleted! " + DateTime.Now; 
        //            Bizs.BizContext.Current.ArticleBiz.Add(article);
        //            break;
        //    }
        //}
    }
}
